<?php
/*
 * Camelot PHP Tools
 *
 * @version 2.0
 * @author Bendsoft
 * @package PHP Tools
 * @subpackage Camelot
 * @license FreeBSD License (www.bendsoft.com/licensing/)
 *
 */

class CamelotList extends Db {

    public $camelot_list_id = 0;
    public $camelot_list_id_external = 0;
    public $camelot_list_title = 0;
    public $camelot_list_description = 0;
    public $camelot_list_schema = 0;
    public $camelot_list_date_modified = 0;
    public $camelot_list_date_lastdeleted = 0;
    public $camelot_list_date_created = 0;
    public $camelot_list_itemcount = 0;
    public $camelot_list_ip = 0;
    public $camelot_list_status = 0;

    public function open($id) {
        if (is_numeric($id)) {
            $sql = "SELECT * FROM camelot_list WHERE camelot_list_id = '$id'";
            $res = parent::DB_SELECT($sql);
            if (mysql_num_rows($res) <> 1) {
                return 0;
            }
        } else {
            $sql = "SELECT * FROM camelot_list " . $id;
            $res = parent::DB_SELECT($sql);
            if (mysql_num_rows($res) <= 0) {
                return 0;
            }
        }


        $data = array();
        while ($row = mysql_fetch_array($res)) {
            $this->camelot_list_id = $row['camelot_list_id'];
            $this->camelot_list_id_external = $row['camelot_list_id_external'];
            $this->camelot_list_title = $row['camelot_list_title'];
            $this->camelot_list_description = $row['camelot_list_description'];
            $this->camelot_list_schema = $row['camelot_list_schema'];
            $this->camelot_list_date_modified = $row['camelot_list_date_modified'];
            $this->camelot_list_date_lastdeleted = $row['camelot_list_date_lastdeleted'];
            $this->camelot_list_date_created = $row['camelot_list_date_created'];
            $this->camelot_list_itemcount = $row['camelot_list_itemcount'];
            $this->camelot_list_ip = $row['camelot_list_ip'];
            $this->camelot_list_status = $row['camelot_list_status'];
            $data[] = (array) $this;
        }
        return $data;
    }

    public function save($id) {
        if ($id > 0) {
            $sql = "UPDATE camelot_list SET camelot_list_id_external = '$this->camelot_list_id_external', camelot_list_title = '$this->camelot_list_title', camelot_list_description = '$this->camelot_list_description', camelot_list_schema = '$this->camelot_list_schema', camelot_list_date_modified = '$this->camelot_list_date_modified', camelot_list_date_lastdeleted = '$this->camelot_list_date_lastdeleted', camelot_list_date_created = '$this->camelot_list_date_created', camelot_list_itemcount = '$this->camelot_list_itemcount', camelot_list_ip = '$this->camelot_list_ip', camelot_list_status = '$this->camelot_list_status' WHERE camelot_list_id = '$id'";
            $res = parent::DB_UPDATE($sql);
        } else {
            $sql = "INSERT INTO camelot_list (camelot_list_id_external, camelot_list_title, camelot_list_description, camelot_list_schema, camelot_list_date_modified, camelot_list_date_lastdeleted, camelot_list_date_created, camelot_list_itemcount, camelot_list_ip, camelot_list_status) VALUES ('$this->camelot_list_id_external', '$this->camelot_list_title', '$this->camelot_list_description', '$this->camelot_list_schema', '$this->camelot_list_date_modified', '$this->camelot_list_date_lastdeleted', '$this->camelot_list_date_created', '$this->camelot_list_itemcount', '$this->camelot_list_ip', '$this->camelot_list_status')";
            $res = parent::DB_INSERT($sql);
        }
        if ($res != 0 || !$res)
            $res = mysql_insert_id();# Instead of RETURNING
        return $res;
    }

    public function update($indata) {
        $sql = "UPDATE camelot_list SET $indata";
        $res = parent::DB_UPDATE($sql);
        if ($res != 0 || !$res)
            $res = mysql_insert_id();# Instead of RETURNING
        return $res;
    }

    public function delete($id) {
        $sql = "DELETE FROM camelot_list WHERE camelot_list_id = '$id'";
        $res = parent::DB_DELETE($sql);
        return $res;
    }


    public function setCamelotListId($camelot_list_id) { $this->camelot_list_id = addslashes($camelot_list_id); }
    public function getCamelotListId() { return stripslashes($this->camelot_list_id); }

    public function setCamelotListIdExternal($camelot_list_id_external) { $this->camelot_list_id_external = addslashes($camelot_list_id_external); }
    public function getCamelotListIdExternal() { return stripslashes($this->camelot_list_id_external); }

    public function setCamelotListTitle($camelot_list_title) { $this->camelot_list_title = addslashes($camelot_list_title); }
    public function getCamelotListTitle() { return stripslashes($this->camelot_list_title); }

    public function setCamelotListDescription($camelot_list_description) { $this->camelot_list_description = addslashes($camelot_list_description); }
    public function getCamelotListDescription() { return stripslashes($this->camelot_list_description); }

    public function setCamelotListSchema($camelot_list_schema) { $this->camelot_list_schema = addslashes($camelot_list_schema); }
    public function getCamelotListSchema() { return stripslashes($this->camelot_list_schema); }

    public function setCamelotListDateModified($camelot_list_date_modified) { $this->camelot_list_date_modified = addslashes($camelot_list_date_modified); }
    public function getCamelotListDateModified() { return stripslashes($this->camelot_list_date_modified); }

    public function setCamelotListDateLastdeleted($camelot_list_date_lastdeleted) { $this->camelot_list_date_lastdeleted = addslashes($camelot_list_date_lastdeleted); }
    public function getCamelotListDateLastdeleted() { return stripslashes($this->camelot_list_date_lastdeleted); }

    public function setCamelotListDateCreated($camelot_list_date_created) { $this->camelot_list_date_created = addslashes($camelot_list_date_created); }
    public function getCamelotListDateCreated() { return stripslashes($this->camelot_list_date_created); }

    public function setCamelotListItemcount($camelot_list_itemcount) { $this->camelot_list_itemcount = addslashes($camelot_list_itemcount); }
    public function getCamelotListItemcount() { return stripslashes($this->camelot_list_itemcount); }

    public function setCamelotListIp($camelot_list_ip) { $this->camelot_list_ip = addslashes($camelot_list_ip); }
    public function getCamelotListIp() { return stripslashes($this->camelot_list_ip); }

    public function setCamelotListStatus($camelot_list_status) { $this->camelot_list_status = addslashes($camelot_list_status); }
    public function getCamelotListStatus() { return stripslashes($this->camelot_list_status); }

}
?>
